<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateAppointmentsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('appointments', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->bigInteger('book_id')->unsigned();
            $table->bigInteger('predecessor_id')->unsigned();
            $table->bigInteger('successor_id')->unsigned();
            $table->integer('stones')->unsigned();

            $table->text('predecessor_comment', 100);
            $table->dateTime('predecessor_confirmed_at');

            $table->text('successor_comment', 100);
            $table->dateTime('successor_confirmed_at');

            $table->char('status', 2)->default('os');
            //os: open by successor;
            //ap: accepted by predecessor;
            //fs: finished by successor receiving the book;

            //ro: replaced by other user who paid more

            //// below to deleted
            //rp: rejected by predecessor
            //cs: canceled by successor

            $table->timestamps();
            $table->softDeletes();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('appointments');
    }
}
